/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class Demo9 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread =new Thread(()->{
            for (int i=0;i<3;i++){
                System.out.println("thread线程");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("thread线程结束");
        });
        thread.start();

        thread.join();
        //thread.join(1000); 也可设置等待时间，时间单位为毫秒
        System.out.println("main线程结束");
    }
}
